{% extends 'base.tpl' %}

{% block title %} 信息泄漏 {% endblock %}

{% block custom_css %} {% endblock %}

{% block page_guider %}
    <ul class="layui-nav">
        <li class="layui-nav-item"><a href="/web/">基础信息</a></li>
        <li class="layui-nav-item"><a href="/web/portscan">端口扫描</a></li>
        <li class="layui-nav-item"><a href="/web/webside">旁站扫描</a></li>
        <li class="layui-nav-item layui-this"><a href="/web/infoleak">信息泄漏</a></li>
      <li class="layui-nav-item">
        <a href="javascript:;">了解更多</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
          <dd><a href="https://blog.dyboy.cn/develop/threatscan.html" target="_blank">使用帮助</a></dd>
          <dd><a href="/static/img/dashang.png" target="_blank">打赏支持</a></dd>
          <dd><a href="https://wpa.qq.com/msgrd?v=3&uin=1099718640&site=qq&menu=yes" target="_blank" title="发起QQ会话">联系作者</a></dd>
          <dd><a href="https://wpa.qq.com/msgrd?v=3&uin=1099718640&site=qq&menu=yes" target="_blank" title="发起QQ会话">意见反馈/指纹提交</a></dd>
        </dl>
      </li>
    </ul>
{% endblock %}

{% block content %}
    <!-- 产品信息 -->
    <div class="threatscan-title">
        <h1> 信息泄漏检查 </h1>
        <p>通过批量扫描检查是否存在信息泄漏问题</p>
    </div>

    <!-- 表单框/提交网址 -->
    <div class="threatscan-search">
        <div class="layui-form">
            <div class="layui-form-item">
              <div class="layui-input-inline">
                <input type="text" name="siteurl" minlength="11" maxlength="39" required="" lay-verify="required" lay-vertype="tips" placeholder="请输入URL" autocomplete="off" class="layui-input">
              </div>
              <button class="layui-btn layui-bg-blue layui-btn-lg btn-scan">泄漏检查</button>
            </div>
        </div>
    </div>

    <!-- 结果展示区 -->
    <div class="threatscan-result" style="display: none;margin-bottom: 150px;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend>查询结果</legend>
        </fieldset>
          <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
              <div class="layui-card">
                <table class="layui-table" lay-even="" lay-skin="nob" style="width: 100%;margin: 10px 0;">
                    <tbody>
                        <tr> <td>类型</td> <td>存在信息泄漏URL</td> </tr>
                    </tbody>
                </table>
              </div>
            </div>
          </div>
    </div>
{% endblock %}

{% block page_js %}
        function get_webside_info(url) {
            $.post('/api/infoleak',{
                url: url
            }, function(data){
                if(data.code == 200){
                    $.each(data.data, function(index, obj){
                        $('tbody').append('<tr><td> ' + obj[0] + ' </td> <td><a href="https://blog.dyboy.cn/go/?url=' + obj[1] +'" target="_blank" title="点击跳转">' + obj[1] + '</a></td></tr>');
                    });
                } else {
                    layer.msg(data.data);
                    $('input[name=siteip]').val('');
                }
                $(".btn-scan").text('重新扫描');
                $('.btn-scan').attr('disabled', false);
            });
        }

        $(function () {
            $(".btn-scan").click(function () {
                $(this).attr('disabled', true);
                var url = $('input[name=siteurl]').val();
                if(url){
                    // 校验当前网址是否正确/符合规范
                    // coding ...
                    if($('.btn-scan').text() == '重新扫描') {
                        $("tbody tr:not(:first)").remove();
                    }
                    $(this).html('请稍等 <i class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>');
                    $('.threatscan-result').show();
                    get_webside_info(url);
                } else {
                    $('input[name=siteip]').val('');
                    layer.msg('请输入正确的URL，\n例如:http://example.cn');
                    $(".btn-scan").text('泄漏检查');
                    $(".btn-scan").attr('disabled', false);
                }
            });
        });
    });

{% endblock %}

